cc.Class({
    extends: cc.Component,

    properties: {
       voiceImg: [cc.SpriteFrame]
    },

    // use this for initialization
    onLoad: function () {
        this.init();
        this.node.children[0].getComponent(cc.Sprite).spriteFrame = this.voiceImg[cc.voicePlay.volume];
        this.thisClick();
    },

    init: function(){
        
    },
    thisClick: function(){
        this.node.on("click", function(){
            cc.voicePlay.volume = cc.voicePlay.volume == 1 ? 0 : 1;
            this.node.children[0].getComponent(cc.Sprite).spriteFrame = this.voiceImg[cc.voicePlay.volume];
            if(cc.voicePlay.volume == 0){
                this.stop();
            }else{
               this.play();
            }
        }, this)
    },

    stop(){
        cc.audioEngine.stopAll();
    },

    play(){
        cc.bgm.play();
    }

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});
